package com.example.carapi.mapper;

import com.example.carapi.bean.CarBrand;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CarBrandMapper {
    @Select("select *\n" +
            "from user\n" +
            "where id=#{id}")
    CarBrand getOne(@Param("id") Long id);

    @Select("select *\n" +
            "from car_brand")
    List<CarBrand> getAll();

    // 数据库已经设置了主键自增，不需要手动插入id了
    @Insert("insert\n" +
            "into car_brand\n" +
            "values(#{name}, #{logo})")
    void insert(CarBrand carBrand);

    @Update("update car_brand\n" +
            "set name=#{name}, logo=#{logo}\n" +
            "where id=#{id}")
    void update(CarBrand carBrand);

    @Delete("delete\n" +
            "from car_brand\n" +
            "where id=#{id}")
    void delete(@Param("id") Long id);
}
